﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TripleGameService
{
    public class GameDTO
    {
        public int id { get; set; }
        public int playerOne { get; set; }
        public int? playerTwo { get; set; }
        public int gameState { get; set; }
        public string boardState { get; set; }
        public string name { get; set; }

        public static GameDTO CreateFromGame(Game game) 
        {
            GameDTO newGame = new GameDTO();
            newGame.id = game.GameId;
            newGame.playerOne = game.PlayerHost;
            newGame.playerTwo = game.OtherPlayer;
            newGame.gameState = game.StateId;
            newGame.boardState = game.BoardState;
            newGame.name = game.GameName;

            return newGame;
        }

        public Game ConvertFromGameDTO() 
        {
            Game newGame = new Game();
            newGame.GameId = this.id;
            newGame.PlayerHost = this.playerOne;
            newGame.OtherPlayer = this.playerTwo;
            newGame.StateId = this.gameState;
            newGame.BoardState = this.boardState;
            newGame.GameName = this.name;
            return newGame;
        }
    }
}